package com.hanthink.web.controller.manhour;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.system.domain.manhour.TheoryAssistWorkSet;
import com.hanthink.system.service.manhour.ITheoryAssistWorkSetService;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 理论辅助用工设定Controller
 * 
 * @author hanthink
 * @date 2022-01-04
 */
@RestController
@RequestMapping("/manhour/TheoryAssistWorkSet")
public class TheoryAssistWorkSetController extends BaseController
{
    @Autowired
    private ITheoryAssistWorkSetService theoryAssistWorkSetService;

    /**
     * 查询理论辅助用工设定列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:list')")
    @GetMapping("/list")
    public TableDataInfo list(TheoryAssistWorkSet theoryAssistWorkSet)
    {
        startPage();
        List<TheoryAssistWorkSet> list = theoryAssistWorkSetService.selectTheoryAssistWorkSetList(theoryAssistWorkSet);
        return getDataTable(list);
    }

    /**
     * 导出理论辅助用工设定列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:export')")
    @Log(title = "理论辅助用工设定", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TheoryAssistWorkSet theoryAssistWorkSet)
    {
        List<TheoryAssistWorkSet> list = theoryAssistWorkSetService.selectTheoryAssistWorkSetList(theoryAssistWorkSet);
        ExcelUtil<TheoryAssistWorkSet> util = new ExcelUtil<TheoryAssistWorkSet>(TheoryAssistWorkSet.class);
        return util.exportExcel(list, "TheoryAssistWorkSet");
    }

    /**
     * 获取理论辅助用工设定详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(theoryAssistWorkSetService.selectTheoryAssistWorkSetById(id));
    }

    /**
     * 新增理论辅助用工设定
     */
    @PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:add')")
    @Log(title = "理论辅助用工设定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TheoryAssistWorkSet theoryAssistWorkSet)
    {
        return toAjax(theoryAssistWorkSetService.insertTheoryAssistWorkSet(theoryAssistWorkSet));
    }

    /**
     * 修改理论辅助用工设定
     */
    @PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:edit')")
    @Log(title = "理论辅助用工设定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TheoryAssistWorkSet theoryAssistWorkSet)
    {
        return toAjax(theoryAssistWorkSetService.updateTheoryAssistWorkSet(theoryAssistWorkSet));
    }

    /**
     * 删除理论辅助用工设定
     */
    @PreAuthorize("@ss.hasPermi('manhour:TheoryAssistWorkSet:remove')")
    @Log(title = "理论辅助用工设定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(theoryAssistWorkSetService.deleteTheoryAssistWorkSetByIds(ids));
    }
}
